<?php
$print = '';
$print2 = '';

if(!isset($_GET['Foto_page'])) $page = 1;
else $page =$_GET['Foto_page'];

if($_SESSION['tb'] % 3 == 0) $print2 = '</tr></table>';
if($_SESSION['tb'] % 3 == 1) $print = '<table><tr>';

if($_SESSION['tb'] == Foto::model()->getCounts()) {
    $print2 = '';
    for($a = 0; $a < (Foto::model()->getCounts() % 3) - 1; $a ++) $print2 .= '<td style="width=33%"></td>';
    $print2 .= '</tr></table>';
}
$size = getimagesize('media/foto/preview/'.$data->link);
echo $print;
?>

<td style="width:33%; padding: 0;  text-align: center;">
    <div class="view"  style="padding: 2px; text-align:  center; padding-left: 0; margin: 5px; border: 0px;" >
        <div id="of">
            <a href="<?php echo $this->createUrl("foto/view", array('id'=>$data->id_foto)) ?>"><img alt="<?php echo $data->name?>" src="media/foto/preview/<?php echo $data->link?> " /></a>
            </div>
    </div>
</td>
<?php echo $print2 ?>
<?php
$_SESSION['tb']++;
//echo $_SESSION['tb'].'-'.Foto::model()->getCounts();
?>